package JavaSEAdvance.day06_Date.D607_HomeWork;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.Date;

/**
 * @author Xiao
 * @date 2021/7/22
 */
public class Test01 {
    /**
     * 1.使用SimpleDateFormat类，把"2018-03-04"转换为"2018年03月04日"。
     */
    public static void main(String[] args) throws ParseException {
        String s = "2018-03-04";
        System.out.println(s);
        System.out.println("------------");
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        Date date = sdf.parse(s);
        SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy年MM月dd日");
        String s1 = sdf2.format(date);
        System.out.println(s1);
        System.out.println("------------");
        LocalDate date1 = LocalDate.parse(s);
        DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy年MM月dd日");
        String s2 = date1.format(formatter);
        System.out.println(s2);
    }
}
